<template>
  <div>
    <div class="table-page-search-wrapper">
      <!-- 搜索区域 -->
      <a-form layout="inline">
        <a-row :gutter="10">
          <a-col :md="10" :sm="12">
            <a-form-item label="用户账号" :labelCol="{span: 6}" :wrapperCol="{span: 18, offset: 1}">
              <a-input placeholder="请输入账号" v-model="queryParam.username"></a-input>
            </a-form-item>
          </a-col>
          <a-col :md="10" :sm="24">
            <a-button type="primary" @click="searchQuery" icon="search" style="margin-left: 18px">查询</a-button>
            <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
          </a-col>
        </a-row>
      </a-form>
    </div>

    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择
        <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>

      <a-table
          ref="table"
          size="middle"
          bordered
          rowKey="id"
          :columns="columns"
          :dataSource="dataList"
          :pagination="ipagination"
          :loading="loading"
          :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
          @change="tableChangeHandle">

        <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)">编辑</a>

          <a-divider type="vertical" />

          <a-dropdown>
            <a class="ant-dropdown-link">
              更多 <a-icon type="down" />
            </a>
            <a-menu slot="overlay">
                <a-menu-item>
                <a href="javascript:;" @click="handleDeptRole(record)">部门角色</a>
              </a-menu-item>

              <a-menu-item>
                <a href="javascript:;" @click="handleDetail(record)">用户详情</a>
              </a-menu-item>

              <a-menu-item>
                <a-popconfirm title="确定取消与选中部门关联吗?" @confirm="() => handleDelete(record.id)">
                  <a>取消关联</a>
                </a-popconfirm>
              </a-menu-item>
            </a-menu>
          </a-dropdown>
        </span>
      </a-table>

    </div>
    <!-- table区域-end -->
  </div>
</template>

<script>
import listMixin from '@/mixins/list-mixin'

export default {
  name: "user-form-card",
  mixins: [listMixin],
  data () {
    return {
      queryParam: {},
      // 表头
      columns: [
        {
          title: '用户账号',
          align: "center",
          dataIndex: 'username'
        },
        {
          title: '用户名称',
          align: "center",
          dataIndex: 'realName'
        },
        {
          title: '电话',
          align: "center",
          dataIndex: 'mobile'
        },
        {
          title: '性别',
          align: "center",
          dataIndex: 'gender',
          customRender: function (text) {
            if (text === 0) {
              return '男'
            } else {
              return '女'
            }
          }
        },
        // {
        //   title: '操作',
        //   dataIndex: 'action',
        //   scopedSlots: { customRender: 'action' },
        //   align: "center",
        //   width: 150
        // }
      ],
      url: {
        list: '/sys/user/page'
      }
    }
  }
}
</script>

<style scoped>

</style>
